package com.todo.biz.application.base.conf;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author azhebuxing
 * @date 2024/12/11 02:20
 * @description
 */
@Configuration
public class BizBaseRabbitConfig {

    public static final String EXCHANGE_BIZ_BASE = "todoStrategy-bizBase";
    public static final String QUEUE_CONTENT_COUNT = "contentCount";
    public static final String QUEUE_USER_STRATEGY_COUNT = "userStrategyCount";
    public static final String QUEUE_PLATFORM_STRATEGY_COUNT = "platformStrategyCount";
    public static final String QUEUE_SIGHT_COUNT = "sightCount";
    public static final String QUEUE_CONTENT_COUNT_ROUTING_KEY = "contentCount";
    public static final String QUEUE_STRATEGY_COUNT_ROUTING_KEY = "strategyCount";
    public static final String QUEUE_SIGHT_COUNT_ROUTING_KEY = "sightCount";

    @Bean
    public DirectExchange bizBaseExchange() {
        return ExchangeBuilder.directExchange("todoStrategy-bizBase").durable(true).build();
    }

    @Bean
    public Queue contentCountQueue(){
        return new Queue(QUEUE_CONTENT_COUNT);
    }
    @Bean
    public Queue userStrategyCountQueue(){
        return new Queue(QUEUE_USER_STRATEGY_COUNT);
    }
    @Bean
    public Queue platformStrategyCountQueue(){
        return new Queue(QUEUE_PLATFORM_STRATEGY_COUNT);
    }
    @Bean
    public Queue sightCountQueue(){
        return new Queue(QUEUE_SIGHT_COUNT);
    }

    @Bean
    public Binding bindingContentCount() {
        return BindingBuilder.bind(contentCountQueue()).to(bizBaseExchange()).with(QUEUE_CONTENT_COUNT_ROUTING_KEY);
    }
    @Bean
    public Binding bindingUserStrategyCount() {
        return BindingBuilder.bind(userStrategyCountQueue()).to(bizBaseExchange()).with(QUEUE_STRATEGY_COUNT_ROUTING_KEY);
    }
    @Bean
    public Binding bindingPlatformStrategyCount() {
        return BindingBuilder.bind(platformStrategyCountQueue()).to(bizBaseExchange()).with(QUEUE_STRATEGY_COUNT_ROUTING_KEY);
    }
    @Bean
    public Binding bindingSightCount() {
        return BindingBuilder.bind(sightCountQueue()).to(bizBaseExchange()).with(QUEUE_SIGHT_COUNT_ROUTING_KEY);
    }
}
